var t = getApp(), e = t.requirejs('core');
Page({
    data: {
        navList: ['业绩记录', '推荐奖励', '复购奖励'],
        activeNav: 1,
        dlagroupid: 0,
        list: [],
        page: 1,
        isEnd: false,
        total: 0
    },
    onLoad(e) {
        console.log(e);
        this.setData({
            dlagroupid: e.id,
        }),
        this.get_list(),
        wx.setNavigationBarTitle({
            title: e.title
        })
    },
    changeNav(s) {
        let activeNav = s.currentTarget.dataset.type
        this.setData({
            activeNav,
            isEnd: false,
            list: [],
            total: 0,
            page: 1,
        }),
        this.get_list()
    },
    get_list() {
        if (this.data.isEnd) return
        e.get("dlcenter/awards/get_list", {page: this.data.page, dlagroupid: this.data.dlagroupid,type:this.data.activeNav}, res => {
            let list = [];
            this.data.page != 1 && (list = this.data.list)
            res.list.length && res.list.forEach(item => {
                list.push(item)
            })
            this.setData({
                list,
                total:res.total
            })
            if(res.total==list.length){
                this.setData({
                    isEnd: true
                })
            }
            
        })
    },
    onReachBottom() {
        !this.data.isEnd && this.setData({
            page: this.data.page + 1
        }), this.get_list()
    }
})